/* t_shmem.cpp : test dgnsc shared memory
 * Copyright (C) 2009-2010 drangon <drangon.zhou@gmail.com>
 * 2009-05
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <dgnsc/shmem.h>
#include <dgnsc/common.h>

#include "gtest.h"

#include <stdio.h>

TEST( shmem, shmem )
{
	char * ptr = NULL;
	int size = 0;
	dgn_shmem_t shm;
	shm = dgn_shmem_init( "test1", 1024 * 1024 );
	dgn_shmem_get( shm, &ptr, &size );
	ptr[0] = 1;
	ptr[1024 * 1024 - 1] = 2;

	int i;
	for( i = 0; i < 20; i++ ) {
		ptr[0] = ptr[0] + 1;
		printf( "%d : ptr[0] %d\n", i, ptr[0] );
		dgn_sleepms( 30 );
	}

	dgn_shmem_fini( shm ), shm = NULL;
}

